<?php
/**
 * 返款明细模型
 * (model)
 */
namespace App\Models\Reimburse;

use App\Models\Basics\SysCountry;
use App\Models\Product\ProductSku;
use App\Models\Product\ProductClassify;
use Illuminate\Database\Eloquent\Model;
class ReimburseDetail extends Model
{
    protected $table = 'reimburse_detail';

    protected $guarded = [];

    public $timestamps = false;

    public static $_fulfillmentType = [
        1 => 'AFN',
        2 => 'MFN'
    ];

    /**
     * 返款申请
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function apply(){
        return $this->belongsTo(ReimburseApply::class,'reimburse_no','reimburse_no');
    }

    public function country(){
        return $this->belongsTo(SysCountry::class,'country_id');
    }

    public function sku(){
        return $this->belongsTo(ProductSku::class,'psku_id');
    }

    public function skuClassify(){
        return $this->hasOneThrough(
            ProductClassify::class,
            ProductSku::class,
            'id',//中间表
            'id',//目标表
            'psku_id',//当前模型
            'classify_id'//中间表
        );
    }
}
